package cn.softgame.cms.secure.nm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.softgame.cms.secure.nm.domain.ResDevModel;
import cn.softgame.cms.secure.nm.domain.ResDevTemplate;
import cn.softgame.cms.secure.nm.persistence.NmMapper;

@Service
public class NmServiceImpl implements NmService {
	
	@Autowired
	private NmMapper mapper;
	
	@Override
	public void save(ResDevModel model) {
		mapper.save(model);
	}
	
	public void update(ResDevModel model) {
		mapper.update(model);
	}

	@Override
	public List<ResDevModel> qryAllDevModels(ResDevModel model) {
		List<ResDevModel> list = mapper.qryAllDevModels(model);
		return list;
	}

	@Override
	public Integer qryTotalRecords(ResDevModel model) {
		return mapper.qryTotalRecords(model);
	}

	@Override
	public void delete(String modelId) {
		mapper.delete(modelId);
	}

	@Override
	public ResDevModel qryDevModelByModelId(String modelId) {
		return mapper.qryDevModelByModelId(modelId);
	}
	
	/**
	 * 根据设备类型查询设备型号
	 * @param type	设备类型：A/B
	 * @return
	 */
	public List<ResDevModel> selectModelsByType(String type){
		return mapper.selectModelsByType(type);
	}

	@Override
	public void updateDevTemplate(ResDevTemplate template) {
		mapper.updateDevTemplate(template);
	}

	@Override
	public void saveDevTemplate(ResDevTemplate template) {
		mapper.saveDevTemplate(template);
	}

	@Override
	public void deleteDevTemplate(String templateId) {
		mapper.deleteDevTemplate(templateId);
	}

	@Override
	public ResDevTemplate qryDevTemplateByTemplateId(String templateId) {
		return mapper.qryDevTemplateByTemplateId(templateId);
	}

	@Override
	public List qryDevTemplates(ResDevTemplate template) {
		return mapper.qryDevTemplates(template);
	}

	@Override
	public int qryDevTemplateTotalRecords(ResDevTemplate template) {
		return mapper.qryDevTemplateTotalRecords(template);
	}
	
	/**
	 * 根据设备类型查询模板
	 * @param modelId
	 * @return
	 */
	public ResDevTemplate getTempleteByModelId(String modelId){
		return mapper.getTempleteByModelId(modelId);
	}
}
